﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ppt2imgWin;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("运行完成！");
            Dictionary<string, string> options = new Dictionary<string, string>();

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].StartsWith("--"))
                {
                    string key = args[i].Substring(2);
                    if (i + 1 < args.Length && !args[i + 1].StartsWith("--"))
                    {
                        options[key] = args[i + 1];
                        i++; // 跳过这个参数的值，因为它已经被处理了
                    }
                    else
                    {
                        options[key] = null; // 如果没有值，可以设置为null或者其他默认值
                    }
                }
            }

            //// 检查特定的选项是否存在
            //if (options.ContainsKey("input"))
            //{
            //    Console.WriteLine($"输入参数: {options["input"]}");
            //}
            //else
            //{
            //    Console.WriteLine("输入参数未指定。");
            //}

            //if (options.ContainsKey("output"))
            //{
            //    Console.WriteLine($"输出参数: {options["output"]}");
            //}
            //else
            //{
            //    Console.WriteLine("输出参数未指定。");
            //}

            if (options.ContainsKey("input") && options.ContainsKey("output"))
            {
                //"D:\\MyTest\\test.pptx";
                string pptFile = options["input"];
                //  "D:\\MyTest\\output1\\";
                string imgDir = options["output"];
                if (!(imgDir.EndsWith("\\") || imgDir.EndsWith("/")))
                {
                    imgDir = imgDir + "\\";
                }

                string result = new OperatePPT().ExportToImg(pptFile, imgDir);
                if (result == "")
                {
                    Console.WriteLine("ppt2image Export success!");
                }
                else
                {
                    Console.WriteLine("ppt2image Export fail!");
                }
            }
            else
            {
                Console.WriteLine("ppt2image input or output param  fail!");
            }
            //Console.WriteLine("运行完成！");
        }
    }
}
